package com.company.pddpre;

import java.util.Arrays;
import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 中餐
        int N = sc.nextInt();
        // 晚餐
        int M = sc.nextInt();
        // 最少
        int T = sc.nextInt();

        int[][] nMeals = new int[N][2];
        int[][] mMeals = new int[M][2];

        for (int i = 0; i < N; i++) {
            // 热量
            nMeals[i][0] = sc.nextInt();
            // 美味
            nMeals[i][1] = sc.nextInt();
        }

        for (int i = 0; i < M; i++) {
            // 热量
            mMeals[i][0] = sc.nextInt();
            // 美味
            mMeals[i][1] = sc.nextInt();
        }

        int res = getLeastHotValue(nMeals, mMeals, N, M, T);

        System.out.println(res);

    }

    private static int getLeastHotValue(int[][] nMeals, int[][] mMeals, int n, int m, int t) {
        int res = Integer.MAX_VALUE;

        if (t == 0) {
            return res;
        }
        // 排序 先按照美味度排 再按照热量排
        Arrays.sort(nMeals, (a, b) -> {
            if (a[1] != b[1]) {
                return a[1] - b[1];
            } else {
                return a[0] - b[0];
            }
        });

        Arrays.sort(mMeals, (a, b) -> {
            if (a[1] != b[1]) {
                return a[1] - b[1];
            } else {
                return a[0] - b[0];
            }
        });
//
//        for (int i = 0; i < n; i++) {
//            System.out.println(nMeals[i][0] + " " + nMeals[i][1]);
//        }
//
//        for (int i = 0; i < m; i++) {
//            System.out.println(mMeals[i][0] + " " + mMeals[i][1]);
//        }

        if (nMeals[n - 1][1] + mMeals[m - 1][1] < t) {
            res = -1;
            return res;
        }

        // 再找到每一个 按从大到小
        int temp_n = 0;
        int temp_m = 0;
        int i = n - 1, j = m - 1;
        while (i >= 0 && nMeals[i][1] >= t) {
            temp_n = nMeals[i][0];
            i--;
        }
        while (j >= 0 && mMeals[j][1] >= t) {
            temp_m = mMeals[j][0];
            j--;
        }

        if(temp_m == 0 && temp_n != 0){
            res = temp_n;
        }
        if(temp_m != 0 && temp_n == 0){
            res = temp_m;
        }

        // 吃一顿的最少热量
        if (temp_m != 0 && temp_n != 0) {
            res = Math.min(temp_m, temp_n);
        }

        // 两顿都吃
        int temp_sum = Integer.MAX_VALUE;
        for (int k = 0; k < n; k++) {

            int nightLeastPos = t - nMeals[k][1];
            int left = 0, right = m - 1;
            while (left < right) {
                int mid = left + ((right - left) >> 1);
                if (mMeals[mid][1] < nightLeastPos) {
                    left = mid + 1;
                } else {
                    right = mid;
                }
            }
            if (left <= m - 1) {
                for(int l = left ;l < m;l++){
                    temp_sum = Math.min(temp_sum, nMeals[k][0] + mMeals[l][0]);
                }

            }
        }

        return Math.min(temp_sum, res);
    }

}
